﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MediaMonitor.Common;
using System.Web.Security;
using Adex;

namespace MediaMonitor
{
    public partial class UserMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

          
            if (!IsPostBack)
            {
                if (Request.RawUrl.Contains("report-all.aspx"))
                {
                    //tdUserMenu.Visible = false;
                }

            }
          
        }

        //Press
        protected void lnkPress_Click(object sender, EventArgs e)
        {
            
            Int32 ModulePermission = 0;
            String UserID = String.Empty;
            Int32 ModuleID = 0;
            ModuleID=6; //For Press
            
            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }
            ModulePermission=  RfController.GetSiteUsers_ModuleStatus(UserID, ModuleID);// 6 For Press
            


            if (ModulePermission == 0)
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
              Response.Redirect(Utility.AppPath + "/users/report-press-filter.aspx");
            }

        }
        //News
        protected void lnkNews_Click(object sender, EventArgs e)
        {

            Int32 ModulePermission = 0;
            String UserID = String.Empty;
            Int32 ModuleID = 0;
            ModuleID = 8; //For News

            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }
            ModulePermission = RfController.GetSiteUsers_ModuleStatus(UserID, ModuleID);// 8 For News



            if (ModulePermission == 0)
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/report-news-filter.aspx");
            }

        }
        //Internet
        protected void lnkInternet_Click(object sender, EventArgs e)
        {

            Int32 ModulePermission = 0;
            String UserID = String.Empty;
            Int32 ModuleID = 0;
            ModuleID = 9; //For Internet

            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }
            ModulePermission = RfController.GetSiteUsers_ModuleStatus(UserID, ModuleID);// 9 For Internet



            if (ModulePermission == 0)
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/report-internet-filter.aspx");
            }


           
        }
        //Outdoor
        protected void lnkOutdoor_Click(object sender, EventArgs e)
        {

            Int32 ModulePermission = 0;
            String UserID = String.Empty;
            Int32 ModuleID = 0;
            ModuleID = 7; //For Outdoor

            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }
            ModulePermission = RfController.GetSiteUsers_ModuleStatus(UserID, ModuleID);// 7 For Outdoor



            if (ModulePermission == 0)
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/report-outdoor-filter.aspx");
            }
        }
        //TVRadioCable
        protected void lnkTVRadioCable_Click(object sender, EventArgs e)
        {
            String ModulePermission = String.Empty;
            String UserID = String.Empty;
            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }

            ModulePermission = RfController.GetSiteUsers_ModuleStatusAll(UserID);

            if (!ModulePermission.Contains("1") && !ModulePermission.Contains("3") && !ModulePermission.Contains("5"))
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/report-tvcr-filter.aspx");
            }
        }

        //ReportMultimedia
        protected void lnkReportMultimedia_Click(object sender, EventArgs e)
        {
            String ModulePermission = String.Empty;
            String UserID = String.Empty;
            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }

            ModulePermission = RfController.GetSiteUsers_ModuleStatusAll(UserID);

            if (!ModulePermission.Contains("1") && !ModulePermission.Contains("3") && !ModulePermission.Contains("5") && !ModulePermission.Contains("6") && !ModulePermission.Contains("7") && !ModulePermission.Contains("9"))
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/report-all-filter.aspx");
            }


        }

        protected void lnkNewsAlert_Click(object sender, EventArgs e)
        {
            Int32 ModulePermission = 0;
            String UserID = String.Empty;
            Int32 ModuleID = 0;
            ModuleID = 10; //For Internet

            MembershipUser memUsr = System.Web.Security.Membership.GetUser();
            if (memUsr != null)
            {
                UserID = memUsr.ProviderUserKey.ToString();
            }
            ModulePermission = RfController.GetSiteUsers_ModuleStatus(UserID, ModuleID);// 9 For Internet



            if (ModulePermission == 0)
            {
                AjaxFuncs.MsgBox(this.Page,
                                       "Please contact the Administrator to add this module.");
                return;
            }
            else
            {
                Response.Redirect(Utility.AppPath + "/users/NewsAlert.aspx");
            }
        }
    
    }
}